C compilers free download :
Turbo C :-
http://www.mediafire.com/download/24i6aw0ucodkp5s/TurboC%2B%2B+for+Windows.exe
DEV C :-
http://www.mediafire.com/download/cezh977kfih19of/Dev-Cpp+5.5.3+TDM-GCC+x64+4.7.1+Setup.exe
**********************************************************
you will find alot of programs in C but am gonna put few..bit unique or difficult one
Can you write a c program without using main function?
We can write a c program without using main function. We can compile it but we cannot execute a program without a main function. Since in C execution of any program start from main function. Examples of c program without a main is all the c library functions. Function printf is an example of library function which has been written and complied without using main function. To use or run such functions we write other program using main function and call those functions.
Code to find the ASCII values of given character in c programming language:
#include<stdio.h>
int main(){
char c;
printf("Enter any character: ");
scanf("%c",&c);
printf("ASCII value of given character: %d",c);
return 0;
}
Sample output:
Enter any character: a
ASCII value of given character: 97
C code for atm transaction while currencies are 1000,500
and 100
2. ATM c program source code
3. C program for atm machine
4. C program for atm banking
#include<stdio.h>
int totalThousand =1000;
int totalFiveFundred =1000;
int totalOneHundred =1000;
int main(){
unsigned long withdrawAmount;
unsigned long totalMoney;
int thousand=0,fiveHundred=0,oneHundred=0;
printf("Enter the amount in multiple of 100: ");
scanf("%lu",&withdrawAmount);
if(withdrawAmount %100 != 0){
printf("Invalid amount;");
return 0;
}
totalMoney = totalThousand * 1000 + totalFiveFundred* 500 + totalOneHundred*100;
if(withdrawAmount > totalMoney){
printf("Sorry,Insufficient money");
return 0;
}
thousand = withdrawAmount / 1000;
if(thousand > totalThousand)
thousand = totalThousand;
withdrawAmount = withdrawAmount - thousand * 1000;
if (withdrawAmount > 0){
fiveHundred = withdrawAmount / 500;
if(fiveHundred > totalFiveFundred)
fiveHundred = totalFiveFundred;
withdrawAmount = withdrawAmount - fiveHundred * 500;
}
if (withdrawAmount > 0)
oneHundred = withdrawAmount / 100;
printf("Total 1000 note: %d\n",thousand);
printf("Total 500 note: %d\n",fiveHundred);
printf("Total 100 note: %d\n",oneHundred);
return 0;
}
Sample output:
Enter the amount in multiple of 100: 7800
Total 1000 note: 7
Total 500 note: 1
Total 100 note: 3
Write a c program which takes password from users
C source code for password:
#include<stdio.h>
#define MAX 500
int main(){
char password[MAX];
char p;
int i=0;
printf("Enter the password:");
while((p=getch())!= 13){
password[i++] = p;
printf("*");
}
password[i] = '\0';
if(i<6)
printf("\nWeak password");
printf("\nYou have entered: %s",password);
return 0;
}
Sample output:
Enter the password:*******
You have entered: fgt67m,
Find gcd of a number using recursion in c program
#include<stdio.h>
int main(){
int n1,n2,gcd;
printf("\nEnter two numbers: ");
scanf("%d %d",&n1,&n2);
gcd=findgcd(n1,n2);
printf("\nGCD of %d and %d is: %d",n1,n2,gcd);
return 0;
}
int findgcd(int x,int y){
while(x!=y){
if(x>y)
return findgcd(x-y,y);
else
return findgcd(x,y-x);
}
return x;
}
No comments:
Post a Comment