Posts

Showing posts with the label basic programming in c

how to print reverse of a number in c++

how to print reverse of a number in c++-
you have given a number for eg. 123456789 and have to print 987654321.

c++ code to print reverse a number=#include<iostream>usingnamespacestd;intmain(){int n; cin>>n;int x;for(x=0;n>0;n = n/10){ x = x*10 + n%10; } cout<<x<<endl; }

find factorial of any number using recursion in c

factorial of any number using recursion in c c language mai recursion ka us krke kisi number ka factorial  #include<stdio.h>           //header file
int fac(int);                     //function definition
void main()                   //main function
{int a,s;                           //main k under k variable
scanf("%d",&a);           //input number by user
s=fac(a);                       // value assigned in s
printf("%d",s);            //s ki final value jo factorial k baad niklegi
}

int fac(int x)                  //fac() function ka declaration
{ if(x==0)
return 1;
x=x*fac(x-1);
return x;
}

c programming/ for loop in c

Image
c# programming
for loop in c





Loop in c language- c# programming
C language mai jab kise statement ko humbaar baar reapeat krwana chate hai to uske liyeloop ka use kiyajata hai Loop ek type ka action statement hai C language mai 3 type k loop hote hai
1-While loop 2-Do while  loop
3-For loop Chalo ab while loop ko example se se smjhte hai:- Agar mai apnenaam ko screen pe 5 baar print krwana chahta hu to mujhe ya to 5 baar printf function ka use krna padega ya 5 baar apna naam likhna padega
But agar mai baar baar likhne se bachana chahta hu toh loop ka use krte hai main() { Int x; clrscr(); scanf(“%d”,&x); while(5>x) //yaha bracket k under condition likhi jati hai agar ye condition true ho to while loopka block chalega agar false ho to nhi chalega yaha maine likha hai ki agar enter kiya gya no 5 se chota hai to while ka box chalao nhi to mat chalao ek baar while ka box chal jaye to condition fir se check kri jayegi agar fir se dobara condition sh…