Você está na página 1de 8

Question NO.

1 /*object:This programme calculate the number of years in which production of computer company exceed 8000 microcomputers if its production increase 12% per year. Name : Muhammad Junaid Aleem class: M.Sc(previous year) Submit to: Sir Nasir .*/ #include<stdio.h> #include<conio.h> void main(void) { clrscr(); float prod,incr; int year; prod=3291; incr=12; printf("A computer company produced 3291 micro computers in 2008."); for(year=2009;prod<=8000;year++) { prod=prod*(1+incr/100.0); printf("\nProduction in the year %d is %f with increment of twelve percent.",year,prod); getch(); } }

Question NO. 2 /*object:This programme will display the halflife of radioactive substance after every 10 days. Name : Muhammad Junaid Aleem class : M.Sc(previous year) submit to : Sir Nasir .*/ #include<stdio.h> #include<conio.h> void main(void) { clrscr(); float emission; int days; emission=1000; printf("present activity of radioactive substance is 1000 emission/sec.\n"); for(days=0;emission>=0.9;days+=10) { printf("emission=%f,days=%d\n",emission,days); emission=(emission/2); getch(); } }

Question NO. 3 /*object:This programme compute the time in which train is stopped if it travelling at 50m/s and slows down 2m/s every second. Name:Muhammad Junaid Aleem class:M.Sc(prev year) submit to :Sir Nasir .*/ #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int speed,time; speed=50; printf("Train travelling at speed of 50m/s.\n"); printf("speed slows down 2m/s every second.\n"); for(time=1;speed>0;time++) { speed=speed-2; printf("\nafter %d second speed is %dm/s\n",time,speed); getch(); } }

Question NO. 4 /*object:This progrmme compute the factorial of number using decrement operator. Name:Muhammad Junaid Aleem class:M.Sc(prev year) submit to:Sir Nasir*/ #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int fact,num,n; while(getche() !='\r') { fact=1; printf("please enter a number:\n"); scanf("%d",&n); for(num=n;num>=1;num--) fact=fact*num; printf("\nfactorial of given number is %d\n",fact); } }

Question NO. 5 /*object:This programme compute factorial of number using decrement operator. Name:Muhammad Junaid Aleem class:M.Sc(prev year) submit to:Sir Nasir */ #include<stdio.h> #include<conio.h> void main(void) { int fact,num,n; while(getche() !='\r') { fact=1; printf("please enter a number:\n"); scanf("%d",&n); num=n; while(num>=1) { fact=fact*num; num--; } printf("\nfactorial of given number is %d\n",fact); } }

Question NO. 6 /*object:This programme compute factorial of number using decrement operator. Name:Muhammad Junaid Aleem class:M.Sc(prev year) submit to:Sir Nasir */ #include<stdio.h> #include<conio.h> void main(void) { int fact,num,n; while(getche() !='\r') { fact=1; printf("please enter a number:\n"); scanf("%d",&n); num=n; do { fact=fact*num; num--; } while(num>=1); printf("\nfactorial of given number is %d\n",fact); } }

Question NO. 7 /*object:This programme display a question and give three attempts to give correct answer. Name:Muhammad Junaid Aleem class:M.Sc(prev year) submit to:sir Nasir */ #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int score,answer; printf("What is the capital of Sindh?\n1-Peshawar\n2-Lahore\n3-Karachi\n4Quetta\nplz give only code of answer\n"); scanf("%d",&answer); if(answer==3) { score=4; printf("\nyour answer is correct and awarded %d points\n",score); } else { printf("\nyour answer is incorrect\ntry again:"); scanf("%d",&answer); if(answer==3) { score=2; printf("\nyour answer is correct and awarded %d points\n",score); } else { printf("\nyour answer is incorrect\ntry again:"); scanf("%d",&answer); if(answer==3) { score=1; printf("\nyour answer is correct and awarded %d points\n",score); } else { printf("\nyou can't give answer in three attempts and awarded zero points"); printf("\nanswer is Karachi."); } } }

getch(); }