Category: C

29
Apr
2017

File Handling in C

Fgets Code: #include<stdio.h> int main() { FILE *fp; fp=fopen(“a.txt”,”r”); //apend mode if(fp==NULL) { printf(“unable to open file\n”);…

28
Apr
2017

Storage Class Specifier: IN C

Auto Example: #include<stdio.h> void main() { Display(); Display(); Display(); } void Display(){ auto int x=1; x=x+5; printf(“%d\n”,x);…

28
Apr
2017

Pointer Good Basic

It will clear the confusion about the pointer when arises. Sum clear: example code: #include<stdio.h> int main()…

21
Apr
2017

Count number of 2’s in a given range (0 to n)? (ex: range between 0-20, Ans: 3 (i.e [2], 1[2], [2]0))

Google Search: https://www.google.com/search?q=Counting+2s&ie=utf-8&oe=utf-8&client=firefox-b#q=Counting+2s+in+c SOlution: https://www.careercup.com/question?id=56794 //https://www.careercup.com/question?id=56794 #include<stdio.h> int main() { int n,i,j; int ctr=0; scanf(“%d”,&n); for(i=0;i<=n;i++) { for(j=i;j>0;j=j/10) {…

20
Apr
2017

Frequency of Digit in A Number

code: //program to cound frequency of digits in a number #include<stdio.h> #define BASE 10 int main() {…

20
Apr
2017

Logic to Find First and Last Digit

Last Digit: #include<stdio.h> int main(){ int num,lastdigit; printf(“enter any number:”); scanf(“%d”,&num); lastdigit=num%10; printf(“lastdigit = %d”,lastdigit); return 0;…