Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

UNITED INTERNATIONAL UNIVERSITY (UIU)

Dept. Of Electrical & Electronic Engineering (EEE)


Exam: Assignment, Trimester: Summer, Year: 2022
Course: EEE 2401 (Sec - A), Title: Structured Programming Language

NAME: Golam Mostofa Md. Habib Ullah Rabbani ID:021201043


ANS 01
#include <stdio.h>
#include <stdlib.h>
int gcd(int a , int b);

int main()
{

return 0;
}
int gcd(int a , int b){
int r ,t=0;
if (a<b){
t=a;
a=b;
b=t;
}
r = a%b;
if (r==0)
return b;
else
return GCD(b , r);

ANS 02
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
int st;
char str1[40], str2[40];
printf("Enter first date (mm/dd/yy): ");
scanf("%s", str1);
printf("Enter second date (mm/dd/yy): ");
scanf("%s", str2);
st =strcmp(str1, str2);
if (st>0)
printf("%s is earlier than %s", str2 , str1);
else if (st<0)
printf("%s is earlier than %s", str1, str2);
else if (st==0)
printf("Two dates are same!");

return 0;

}
ANS 03
#include <stdio.h>
#include <stdlib.h>
int main()
{
char c;
FILE *fa, *fb;
fa =fopen("a.txt", "r");
fb =fopen("b.txt", "w");
while((c = fgetc(fa)) != EOF) {
if(c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c
== 'o' || c == 'O' || c == 'u' || c == 'U')
fprintf(fb,"%c", c);
}

return 0;

}
ANS 04
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Student {
char* name;
char* City;
int Student_ID;
};
int main()
{
int i = 0, n = 5;
struct Student student[n];
student[0].Student_ID = 136;
student[0].name = "ACB";
student[0].City = "Barisal";
student[1].Student_ID = 125;
student[1].name = "ABC";
student[1].City = "Sylhet";
student[2].Student_ID = 115;
student[2].name = "DEF";
student[2].City = "Dhaka";
student[3].Student_ID = 104;
student[3].name = "DSM";
student[3].City = "Chittagong";
student[4].Student_ID = 123;
student[4].name = "CBA";
student[4].City = "Rajshahi";
printf("Information of student:\n\n");
printf("\t Name \t Student_ID \t City\n");
for (i = 0; i < n; i++) {
printf("\t %s", student[i].name);
printf("\t\t %d", student[i].Student_ID);
printf("\t %s\n", student[i].City);
}
return 0;
}

You might also like