Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 47

Portfolio Submission

Md Nahid Hassan Utso


Id:2020-2-1-089

Mid 1-
#include<stdio.h>
int main()
{
int a=12,b=10;
float c=11.5,d=99.5;
printf("++a=%d\n",++a);
printf("--b=%d\n",--b);
printf("++c=%.2f\n",++c);
printf("--d=%.2f\n",--d);
return 0;
}
#include <stdio.h>
int main() {
int totalSeconds, hours, minutes, seconds;
// Input the total number of seconds
printf("Enter the total number of seconds: ");
scanf("%d", &totalSeconds);
// Calculate hours, minutes, and remaining seconds
hours = totalSeconds / 3600;
totalSeconds %= 3600;
minutes = totalSeconds / 60;
seconds = totalSeconds % 60;
// Output the result
printf("The equivalent time is: %d hours, %d minutes, and %d seconds\n",
hours, minutes, seconds);
return 0; }

#include <stdio.h>
void main ()
{
int amt, total;
printf("enter amount: ");
scanf ("%d",&amt);
total= amt/1000;
printf("there are: ");
printf ("\n%d notes of 1000\n", total);
amt=amt-(total*1000);
total=amt/500;
printf ("\n%d notes of 500\n", total);
amt=amt-(total*500);
total=amt/200;
printf ("\n%d notes of 200\n", total);
amt=amt-(total*200);
total=amt/100;
printf ("\n%d notes of 100\n", total);
amt=amt-(total*100);
total=amt/50;
printf ("\n%d notes of 50\n", total);
amt=amt-(total*50);
total=amt/20;
printf ("\n%d notes of 20\n", total);
amt=amt-(total*20);
total=amt/5;
printf ("\n%d notes of 5\n", total);
amt=amt-(total*5);
total=amt/2;
printf ("\n%d notes of 2\n",total);
amt=amt-(total*2);
total=amt/1;
printf ("\n%d notes of 1\n",total);
}
#include<stdio.h>
int main()
{
float costprice,sellingprice,profitloss;
printf("Enter your cost price");
scanf("%f",&costprice);
printf("Enter your selling price")
;scanf("%f",&sellingprice);
profitloss=(sellingprice-costprice);
if(profitloss>0)
{
printf("profit:%.2f",profitloss);
}
else if(profitloss<0)
{
printf("Loss:%.2f",profitloss);
}
else
{
printf(" no profit no losss\n");
}
return 0;}

#include<stdio.h>
void main()
{
float bs,hr,da,gross;
printf("please enter basic salary: ");
scanf("%f", &bs);
if(bs>20000){
hr = bs*.30;
da = bs*.50;
}
else if(bs>10000){
hr = bs*.25;
da = bs*.40;
}
else {
hr = bs*.20;
da = bs*.30; }
gross = bs+hr+da;
printf("Total Salary or Gross Salary is %.2f\n",gross);}

#include<stdio.h>
void main()
{
int a=5,c;
c=a;
printf("c=%d\n",c);
c+=a;
printf("c=%d\n",c);
c-=a;
printf("c=%d\n",c);
c*=a;
printf("c=%d\n",c);
c/=a;
printf("c=%d\n",c);
c%=a;
printf("c=%d\n",c);
}

#include<stdio.h>
int main()
{
char ch='x';
char str[20]="www.ewubd.edu";
float pi=3.14159;
int no=220;
double dbl=60.1234567;
printf("character %c\n",str);
printf("string is %n",str);
printf("float valueis %f\n",pi);
printf("integer value is %d\n",no);
printf("Double value is %if\n",dbl);
printf("Octal value is %o\n",no);
printf("Hexadecimal value is %x\n",no);
return 0;
}

#include<stdio.h>
int main()
{
int a;
char ch;
char myname[20];
printf("please enter an integer value of a: ");
scanf("%d",&a);
printf("value of a is %d\n",a);
printf("please enter an character of ch: ");
scanf("%c",&ch);
printf("value of a is %d",a);
printf("please enter a string of myname: ");
scanf("%s", myname);
printf("value of a is %s",myname);
return 0;
}

#include <stdio.h>
int main() {
int number, dividedBy4, dividedBy12;
printf("Enter a number: ");
scanf("%d", &number);
// Divide the number by 4 and store the result in dividedBy4
dividedBy4 = number / 4;
// Divide the number by 12 and store the result in dividedBy12
dividedBy12 = number / 12;
printf("The number divided by 4 is: %d\n", dividedBy4);
printf("The number divided by 12 is: %d\n", dividedBy12);
return 0;
}

//calculate compound interest


#include<stdio.h>
#include<math.h>
void main()
{
float p,r,n,i;
printf("Enter your principle amount:\n");
scanf("%f",&p);
printf("Enter your rate:\n");
scanf("%f",&r);
printf("Enter your number of years:\n");
scanf("%f",&n);
r=r/100;
i=pow(1+r,n);
printf("Future value:%.2f",i*p);
}

//Write a C program to show given number

#include <stdio.h>

void main()
{
int number;
printf("enter an integer number:");
scanf ("%d",&number);
if(number%2==0)
{
printf("%d is even number",number);
}
else
{
printf("%d is odd number",number);}}

#include <stdio.h>
void main ()
{
float MIS401,MIS101,MIS415,MIS410;
float avg,per;
printf("Enter the marks for all course: \n");
scanf("%f%f%f%",&MIS101,&MIS101,&MIS415,&MIS410);
float total=(MIS401+MIS101+MIS415+MIS410);
avg=total/4.0;
per=(total/400.00)*100;
printf("Total marks for all subject: %.2f\n", total);
printf("Averege for all subject: %.2f\n", avg);
printf("percentage for all subject: %.2f\n", per);}

#include<stdio.h>
void main()
{
int year ;
printf("enter a year to check if it is leap year: ");
scanf ("%d",&year);
if((year%4==0)&&(year%100!=0)|| (year%400==0))
printf("%d is a leap year\n",year);
else
printf("%d is not a leap year\n",year);}
#include<stdio.h>
void main ()
{ int d,m,y;
printf("Enter number of days:\n");
scanf("%d",&d);
y=d/365;
printf("Year :%d \n",y);
d=d-(y*365);
m=d/30;
printf("Month:%d \n",m);
d=d-(m*30);
printf("Day :%d \n",d);}
#include<stdio.h>
int main()
{
char ch;
printf("Enter a Alphabet");
scanf("%c",&ch);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
{
printf("The Alphabet is vowel");
}
else{
printf("The Alphabet is consonent");
}
return 0;
}
Mid -2
#include<stdio.h>
void main()
{
int n=1,limit;
printf("Enter the No. of limit::");
scanf("%d",&limit);
stop:
printf("%d\t",n);
n++;
if(n<=limit)
goto stop;}
#include<stdio.h>
void main()
{
int a,sum=0;
float n,avg;
printf("Enter numbers:");
scanf("%f",&n);
for(a=1;a<=n;a++)
{
sum=sum+a;
printf("%d\n",a);
}
printf("sum is :%d\n",sum);
avg=sum/n;
printf("Average is:%.2f\n",avg);}
#include<stdio.h>
#include<conio.h>
void main()
{
char username[15];
char pass[20];
printf("Please enter Username:");
scanf("%s",&username);
printf("please enter password:");
scanf("%s",&pass);
if(strcmp(username,"Eastwest")==0&&strcmp(pass,"Student")==0)
printf("Login Sucsessful.\n");
else
printf("Login Unsucsessful.\n");}
#include<stdio.h>
void main()
{
int id;
printf ("please enter ID: ");
scanf("%d",&id);
switch (id)
{
case 1:
printf("We are learning Web programming!");
break;
case 2:
printf("We are learning c programming ! ");
break;
case 3:
printf(" We are learning python programming!");
break;
default:
printf("No student found");
break;}}

#include<stdio.h>
void main()
{
int cust_Id,consume;
char c_name[15];
float charge,surcharge=0, gramt, netamt;
printf("please enter customer ID:");
scanf("%d",&cust_Id);
printf("please enter Customer Name: ");
scanf("%s",c_name);
printf("please input the unit consumed by the customer Name: ");
scanf("%d",&consume);
if(consume<200)
charge=2.20;
else if(consume>=200 && consume<400)
charge=3.50;
else if(consume>=400 && consume<600)
charge=4.80;
else
charge=8.50;
gramt=consume* charge;
if(gramt>500)
surcharge=gramt*15/100.00;
netamt=gramt + surcharge;
netamt=200;
printf("Electricity bill\n");
printf("Customer ID: %d \n",cust_Id);
printf("Customer Name: %s \n",c_name);
printf("Unit consumed: %d \n",consume);
printf("==================\n");
printf("Amount charge BDT. %.2f per unit %.2f\n",charge,gramt);
printf("Surcharge Amount: %.2f\n",surcharge);
printf("Net amount paid by the Customer: %.2f\n",netamt);
}
#include<stdio.h>
void main()
{
int a;
for(a=1;a<=10;a++)
{
printf("Nahid\n");}}
#include<stdio.h>
void main()
{
int a,b;
for(a=1,b=1;a<5 || b<7;a++,b++)
{if(a==6)
{
break ;
}
printf("%d %d\n",a,b);}}

#include<stdio.h>
void main()
{
int a,sum=0;
printf("The first 10 numbers:");

for(a=1;a<=10;a++)
{
sum=sum+a;
printf("%d\n",a);
}
printf("sum is :%d",sum);
}

#include<stdio.h>
void main()
{
int age;
masud:
printf("Please enter age between 18 to 30:\n");
scanf("%d",&age);
if(age<18 || age>30)
{
printf("Incorrect age! Please enter age between 18 to 30.\n");
goto masud;
}
else
printf("you are correct! You entered age is:%d\n",age);}}

#include <stdio.h>
void main(){
int alph;
printf("Please enter Alphabet (A to Z or a to z): ");
scanf("%d",&alph);
switch (alph){
case 'a':
case 'A':
case 'E':
case 'e':
case 'I':
case 'i':
case 'O':
case 'o':
case 'U':
case 'u':
printf("Your Alphabet is Vowel\n");
break;
default:
printf("Your Alphabet is Consonent\n");
break;}}

#include<stdio.h>
void main()
{
int no1,no2;
float result =0.0;
char ch;
printf("Enter no1:");
scanf("%d",&no1);
printf("Enter no2:");
scanf("%d",&no2);
printf("choose operation perform (+,-,*,/,%): ");
scanf(" %c",&ch);
switch(ch)
{
case '+':
result=no1+no2;
break;
case '-':
result=no1-no2;
break;
case '*':
result=no1*no2;
break;
case '/':
result=no1/no2;
break;
case '%':
result=no1%no2;
break;
default:
printf("you entered invalid operation\n");
break;
}
printf("Resolve : %d %c %d=%.2f\n", no1,ch,no2,result);
}
#include<stdio.h>
void main()
{
int hh,mm,ss;
start:
printf("Please enter in HH:MM:SS format:\n");
scanf("%02d:%02d:%02d",&hh,&mm,&ss);
if(hh<0 || hh>23 || mm<0||mm>59||ss<0||ss>59)
{
printf("Incorrect Time: please enter time in HH:MM:SS format.\n");
goto start;
}
else{
printf("You are correct !\n");
printf("The time is %02d:%02d:%02d\n",hh,mm,ss);
}}
#include<stdio.h>
void main()
{
int a,limit;
printf("Enter your value of Limit:");
scanf("%d",&limit);
for(a=limit;a>=1;a--)
{
printf("%d\n",a);
}}
#include<stdio.h>
void main()
{
int a,n;
printf("Enter your value N:");
scanf("%d",&n);
for(a=1;a<=n;a++)
{
printf("%d\n",a);
}}
#include<stdio.h>
void main()
{
char username;
int password;
printf("Please enter Username:");
scanf("%c",&username);
printf("please enter password:");
scanf("%d",&password);
if(username=='N')
{
if(password==123456)
{
printf("Login Succsessful!");
}
else
{
printf("Password incorrect!");
}
}
else
{
printf("Username is incorrect!");
}}

#include<stdio.h>
void main()
{
int month,days;
printf("Enter month (1-12):");
scanf("%d",&month);
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days =31;
printf("Number of days in %d month is: %d\n",month,days);
break;
case 2:
days=28;
printf("Number of days in %d month is: %d\n",month,days);
break;
case 4:
case 6:
case 9:
case 11:
days=30;
printf("Number of days in %d month is: %d\n",month,days);
break;
printf("Your month is 30 days\n ");
default:
printf("Enter month (1-12):");
break;
}
if (days)
printf("Number of days in %d month is :%d\n",month,days);
else
printf("You have entered ivalid number");
}

Final exam:
#include<stdio.h>
void main()
{
int n,r,sum;
printf("The perfect number in between 1 to 500 ");

for(n=1;n<=500;n++)
{
r=1; sum=0;
while (r<n){
if(n%r==0)
sum=sum+r;
r++;
}
if(sum==n)
printf("%d\t",n);
}}

#include <stdio.h>
void main(){
int n=1;
do{
printf("%d\t",n);

n+=2;
}while(n<=20);
}
#include<stdio.h>
void main()
{
int n,r,sum,min,max;
printf("Enter minimum number:");
scanf("%d",&min);
printf("Enter maximum number:");
scanf("%d",&max);
printf("Perfect numbers in given range is:");
for(n=min;n<=max;n++)
{
r=1;sum=0;
while(r<n){
if(n%r==0)
sum=sum+r;
r++;
}
if(sum==n)
printf("%d\t",n);
}}

//nested loop
#include<stdio.h>
void main()
{
int a,b,m,n;
printf("Enter value for M:");
scanf("%d",&m);
printf("Enter value for N:");
scanf("%d",&n);
for (a=1;a<=m;a++)
{
for(b=1;b<=n;b++)
{
printf("%d\t",a*b);

}
printf("\n");
}
}

#include <stdio.h>
void main(){
int n, r,k, rev=0;
printf("Enter any number: ");
scanf("%d",&n);
k=n;
while(n){
r=n%10;
rev=rev*10+r;
n=n/10;
}
printf("Reverse number is: %d\n",rev);
if(k==rev)
printf("This number is Palindrome.");
else
printf("This number is not Palindrome.\n");
}

#include<stdio.h>
void main()
{
int n,r=1,sum=0;
printf("Enter number: ");
scanf("%d",&n);
while(r<n)
{
if(n%r==0)
sum=sum+r;
}
}

printf("Perfect numbers in given range is: ");

for(n=1;n<=28;n++){
r=1; sum=0;

while(r<n){

if(n%r==0)
sum= sum+r;
r++;
}
if(sum==n)
printf("%d\t",n);
}
}

#include<stdio.h>
void main()
{
int n,r,k,rev=0;
k=n;
while(n)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
printf("Reverse of number:%d\n",rev);
if(k==rev)
printf("This number is palindrome.");
else
printf("This number is not palindrome.");
}

#include<stdio.h>
void main()
{
int a,b,c;
for (a=1;a<=3;a++)
{
for(b=1;b<=3;b+2)
{
for(c=1;c<=3;c++){
printf("%d %d %d\t",a,b,c);
}
}
printf("\n");
}}

#include<stdio.h>
void main()
{
int a,b;
for (a=1;a<=5;a++)
{
for(b=1;b<=a;b++)
printf("%d ",a);
printf("\n");
} }
#include<stdio.h>
void main()
{
int a,b;
for (a=1;a<=3;a++)
{
for(b=1;b<=3;b++)
{
if(a==2 && b==2)
{
continue;
}
printf("%d %d\t\n",a,b);
}
printf("\n"); }}
#include<stdio.h>
void main()
{
int a,b,c;
for (a=1;a<=3;a++)
{
for(b=1;b<=2;b++)
{
for(c=1;c<=3;c++)
{
printf("%d %d %d\t\n",a,b,c);
}
}
printf("\n");
}}

You might also like