Pages

Wednesday, October 24, 2012

A program that finds the Fibonacci series for first 30 numbers.


   A program that finds the Fibonacci series for first 30 numbers.
  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. long long int i,f1,f2,f;
  6. clrscr();
  7. f1=0;f2=1;
  8. printf("\n\n%llu %llu",f1,f2);
  9. f=0;
  10. for(i=3;i<=30;i++){
  11. f=f1+f2;
  12. printf(" %llu ",f);
  13. f1=f2; f2=f;
  14. }
  15. getch();

Tuesday, October 23, 2012

How to find GCD of two number in c

# A Program of finding GCD of Two Number.

  1. #include<stdio.h>
  2. intd,x,y;
  3. void s(inta,int b){
  4. int z;
  5. if(b>a){
  6. z=a;a=b;b=z;}
  7. if(b==0)
  8. {d=a;
  9. x=1;
  10. y=0;
  11. return ;}
  12. s(b,a%b);
  13. d=d;
  14. z=x-(a/b)*y;
  15. x=y;
  16. y=z;}
  17. int main ()
  18. {inta,b;
  19. scanf ("%d  %d",&a,&b);
  20. s(a,b);
  21. printf("\ngcd=%d   x=%d   y=%d\n",d,x,y);
  22. return 0;
  23. }

How can i find the sum of all odd number between a range.

#A program that finds the sum of all odd numbers between M to N.

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. long long int i,m,n,sum;
  6. clrscr();
  7. FILE *p;
  8. p=fopen("file5.txt","r");
  9. fscanf(p,"%lld %lld",&m,&n);
  10. for(i=m;i<=n;i++){
  11. if(i%2==1)
  12. printf(" %lld ",i);}
  13. sum=0;
  14. for(i=m;i<=n;i++){
  15. if(i%2==1)
  16. sum=sum+i;}
  17. printf("\n\nSum of ODD numbers=%lld\n",sum);
  18. getch();
  19. }

// in Notepade  wirte m=10 and n=100 then save as file5.txt//

 RULES & output:
1.Program type:used by for loop and if.
2.Simple input:10-100
3.Simple output:11 13 15 17 19 21 23 ………………99.
 Sum=2475.

How to find all prime number between a range.

# A program to print all prime  numbers between-10 to 100.

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int i,n,f,rang,c;
  6. clrscr();
  7. for(n=10;n<=100;n++){
  8. f=0;
  9. for(i=2;i<n;i++)
  10. if(n%i==0){
  11. f=1;
  12. break;}

  13. if(f==0)
  14. printf("%d ",n);
  15. else
  16. printf(" ");
  17. }
  18. getch();
  19. }

RULES & output:
1.Program type:used by for loop and if else.
2.Simple input:10-100
3.Simple output:11 13 17 19 23 ………………97.

Tuesday, October 9, 2012

Here you know how to print HELLO WORLD in assembelly.



·          First Programm In assembelly: HELLO WORLD PRINT
1.       .MODEL SMALL
2.       .STACK 100H
3.       .DATA
4.       MSG DB 'HELLO world! $'
5.       .CODE
6.       MAIN PROC       
7.       MOV AX,@DATA    ; INITIALIZE DS
8.       MOV DS, AX
9.       LEA DX, MSG            ; LOAD &DISPLAY MASSAGE
10.   MOV AH, 9
11.   INT 21H
12.   MOV AH, 4CH          ; DOS EXIT
13.   INT 21H
14.   MAIN ENDP
15.   END MAIN

Monday, October 8, 2012

How to use various function in c++

#A program that will you intruduce with some new function of c++.
  1.  #include<iostream>
  2.  using  namespace std;
  3.  void  line(),massage();
     int main(){
  4.  line();
  5.  massage();
     cout<<endl<<"oh yes"<<endl<<"what a happy day"<<endl<<"oh what"<<endl<<"what a    nice day";
  6.  return 0;  }

     void  line(){
     cout<<"oh what\n";  }
  7.  void  massage(){cout<<"A happy day\n"<<endl;}

A Programm that will introduce you with some c++ function calling.

// This programm code is written on codeblock
  1. #include<iostream>
  2.   using  namespace std;
  3.   void  line(),massage();
  4. int main(){
  5.     line();
  6.     massage();
  7.     line();
  8.     cout<<"The end of main ().\n";
  9.     return 0;
  10.     }
  11.   void  line(){
  12.         cout<<"-------------------------------------------------------\n";
  13.     }
  14.    void  massage(){
cout<<"Enjoying c++ laguahe\n"<<endl;
}

Sunday, October 7, 2012

A program that read a line of text and display number of upper case, lower case, digit, space and other characters

 This code is written on  Turbo c Compailer..
#include<stdio.h>
#include<conio.h>
#include<string.h>

void main() 

charst[100]; 
inti,l,upper=0,lower=0,digit=0,space=0,other=0; 

clrscr(); 
printf("Enter any line: "); 
gets(st); 

   l=strlen(st); 
for (i=0; i<l; i++) 
if (st[i]>='a' &&st[i]<='z') 
lower++; 
else if (st[i]>='A' &&st[i]<='Z') 
upper++; 
else if (st[i]>='0' &&st[i]<='9') 
digit++; 
else if (st[i]==' ') 
space++; 
else
other++; 

printf("\nUpper= %d",upper); 
printf("\nLower= %d",lower); 
printf("\nDigit= %d",digit); 
printf("\nSpace= %d",space); 
printf("\nOther= %d",other); 
getch(); 



How can i convert a line of upper case to lower case

 #A program that convert a line to lower case

 



   1.  #include<stdio.h> 
2.  #include<conio.h> 
3.  #include<string.h> 
4.   
5.  void main() 
6.  { 
7.     char st[100]; 
8.     int i,l; 
9.   
10.    clrscr(); 
11.    printf("Enter any line: "); 
12.    gets(st); 
13.  
14.    l=strlen(st); 
15.    for (i=0; i<l; i++) 
16.    if (st[i]>='A' && st[i]<='Z') 
17.    printf("%c",st[i]+32); 
18.    else 
19.    printf("%c",st[i]); 
20.    getch(); 
21. } 

Friday, October 5, 2012

A program that read any upper case character and display in lower case



 
 
# A program that read any upper case character and display in lower case                     
 
    
    1.  #include<stdio.h> 
2.  #include<conio.h> 
3.   
4.  void main() 
5.  { 
6.     char n; 
7.   
8.     clrscr(); 
9.     printf("Enter any upper case character: "); 
10.    scanf("%c",&n); 
11.  
12.    printf("%c",n+32); 
13.    getch(); 
14. }