#include<stdio.h> int main() { int i, j, temp, arr[10]; printf(“Enter the number with some repeated number\n”); for(i
Tag: C questions
C questions for exam preparation, campus interview preparation and C skills/knowledge build up.
Q24 Write a C program to convert from decimal to binary, octal, or hex number system.
#include<stdio.h> void decimal_to_any_base(int number, int base) { int i, x, digits[1000], flag; i = 0; while(number)
Q23 Write a C program which produces its own source code as its output.
#include<stdio.h> int main() { FILE *fptr; char chr; fptr = fopen(__FILE__,”r”); do{ chr= getc(fptr); putchar(chr); } while(chr!=EOF); fclose(fptr); return 0;
Q22 How to add sum the digits of a given number in single statement?
Twisted question from interviewer, but not difficult. for(; num > 0; sum += num%10, num /= 10); printf(“Sum = %d\n”,sum);
Q14. Write a C program to reverse the place of words in a sentence.
Suppose input is “Welcome to gyantoday” then output should be “gyantoday to welcome” Steps of algorithm: Reverse whole sentence first.
Q31 What is lvalue and rvalue?
lvalue stands for left value of assignment operator and rvalue is stands for right value of assignment operator. Exapmle: value