Subscribe For Free Updates!

We'll not spam mate! We promise.

Showing posts with label C++. Show all posts
Showing posts with label C++. Show all posts

Sunday, 26 August 2012

C code to Displating percentage and grade of student


// Displating percentage and grade of student
// Programmer name: Sohail Ahmed
// 13/04/2011

#include<conio.h>
#include<stdio.h>

void main()
{
clrscr();
float eng, itp, eca, cal, per;
int op;
char loop;
do{
clrscr();
printf("\n\tEnter marks of English: ");
scanf("%f", &eng);
printf("\n\tEnter marks of ITP: ");
scanf("%f", &itp);
printf("\n\tEnter marks of ECA: ");
scanf("%f", &eca);
printf("\n\tEnter marks of Calculas: ");
scanf("%f", &cal);
per=(eng+itp+eca+cal)/400*100;
getch();
clrscr();
printf("\n\t***Menu***"
      "\n\t1. Percentage"
      "\n\t2. Grade"
      "\n\t3. Grade of Each sub");
printf("\n\n\tEnter any Option: ");
scanf("%d", &op);
switch(op)
{
case 1:
printf("\n\tYou have got %.2f Percentage", per);
break;
case 2:
if(per<40)
{
printf("\n\tSorry you are Failed");
}
else if(per<90)
{
printf("\n\tYou have got B Grade");
}
else
{
printf("\n\tCongrates you have got A grade");
}
break;
case 3:
printf("\nMarks of all Subjects");
printf("\nEnglish =\t\t%.1
f", eng);
printf("\nIntroduction to Prog =\t%.1f", itp);
printf("\nElectric Circuits =\t%.1f", eca);
printf("\nCalculas =\t\t%.1f", cal);
break;
default:
printf("\n\tInvalid option");
}
getch();
clrscr();
printf("\n\tDo you want to Continue....(Y OR N)");
loop=getche();
}while(loop=='Y' || loop=='y');
getch();
}

C code to display in full payment and in installments



// Program to show in full payment and in installments
// Programmer name: Sohail ahmed
// Dated: 07/04/2011

#include<conio.h>
#include<stdio.h>

void main()
{
clrscr();
float pay, dis, payable;
char op_lop;
int op;
do{ // Starting of Do-while
clrscr();
printf("\nEnter Payment: ");  // input full payment
scanf("%f", &pay);
clrscr();
printf("\n1. Full payment\n2. Two Instalments\n3. Three instalments\n\n");
printf("\nEnter any option: ");  // input of option of above menu
scanf("%d", &op);
clrscr();
switch(op)
{
case 1: // 1st option
{
dis=pay*15/100;
payable=pay-dis;
printf("\n\nTotal amount:\t%.2f", pay);
printf("\n\nDiscount:\t%.2f", dis);
printf("\n\nAmount Payable:\t%.2f", payable);
break;
}               //end
case 2:   // 2nd option
{
dis=pay*10/100;
payable=pay-dis;
printf("\n\nTotal amount:\t%.2f", pay);
printf("\n\nDiscount:\t%.2f", dis);
printf("\n\nAmount Payable:\t%.2f", payable);
printf("\n\nTwo instalments to be paid of amount %.2f", payable/2);
break;
}//end
case 3:  // 3rd option
{
dis=pay*5/100;
payable=pay-dis;
printf("\n\nTotal amount:\t%.2f", pay);
printf("\n\nDiscount:\t%.2f", dis);
printf("\n\nAmount Payable:\t%.2f", payable);
printf("\n\nThree instalments to be paid of amount %.2f", payable/3);
break;
} //end
default:            // default
{
printf("\n\n*****Invalid Option*****");
}
} //end
getch();
clrscr();
printf("\nDo you want to continue(Y OR N):"); // program should b continue or not
op_lop=getche();
}while(op_lop=='y' || op_lop=='Y'); // loop condition
getch();
}

Printing defined sentence with C language



// Printing defined sentence
// Programmer name: Sohail ahmed
// Date: 26/02/2011

#include<stdio.h>
#include<conio.h>

void main(void)
{
clrscr();
printf("\"Hello World\n\nThis is my first program.\n\nI can change the world.\n\n\"");
getch();

}

Printing number with C language



// Printing the number
// Programmer name: Sohail ahmed
// Date: 26/02/2011

#include<stdio.h>
#include<conio.h>

void main(void)
{
clrscr();
printf ("This is the number two:%d",2);
getch();
}