C questions and answers

C questions and answers with explanation

1. Data types        2. Operators              3. Pointers
4. Arrays            5. Loops                  5. Preprocessor
6. Structures        6. If else                6. Switch case
7. printf            8. Variables              7. File handling
8. Strings           9. Command line arguments

C questions and answers for interview

Online Tests

1. Practice set 1    2. Practice set_2         3. Practice set_3

C tutorials:

1. Memory mapping    2. Variables              3. Data types
4. Storage Class     5. Looping                5. Pointers
6. Functions         6. Arrays                 6. Preprocessor
7. File handling     8. Advance c    
         
C pdf to free download


1. Faq pdf           2. C in depth pdf         3. MCQ pdf 
4. Objective 1 pdf   5. C langauge pdf         6. C questions pdf
7. Pointers pdf      6. Interview pdf          8. C Test 1 pdf
Good tricky questions

1. Best c questions   2. Tricky c questions      3. MCQ  4. C in Linux 

C program examples FAQ:

1. Fibonacci series    2. Check prime number        3. Find factorial
4. Check Palindrome    5. Reverse string            6. Check Armstrong                 7. Quadratic equation  9. Concatenate string          8. Reverse numbers  

C programs on numbers

1. Sum of digits        2. Find Power       3. Addition(Without using +)


C program on strings

1. Upper to Lower      2. Lower to upper      3. Print initials
4. Delete consonants   5. String palindrome   6. Sort the characters
LCM and HCF

1. LCF          2. HCF              3. GCD

Sorting

1. Selection sort    2. Quick sort            3. Insertion sort
4. Bubble sort       5. Merge sort             6. Heap sort

Searching

1. Linear search     2. Binary search

Swapping

1. Two numbers       2. Swap two string        3. Swap two arrays
Conversion

1. Binary to decimal     2. Binary to octal      3. Binary to hex
7. Octal to binary       8. Octal to decimal     9. Octal to hex
10. Hex to binary        11. Hex to decimal      12. Hex to Octal             
13. Decimal to Roman     14. Roman to decimal    15. Digits to word 
16. Currency to word     17. Units conversion    18. String to int
Matrix

1. Addition         2. Subtraction          3. Multiplication
4. Division         5. Transport            6. Sum of diagonal elements
7. Inverse          8. Determinants         9. Scalar multiplication
File

1. Write text and close     2. Delete a file 3. Copy from one 
location to other           4. Copy data of file
5. Display source code as output     6. Write string in the file
11. Find size and drive of file      12. Know type of file          
Complex number

1. Print complex number    2. Addition & subtraction    
3. Multiplication
4. Division

Array

C program using function recursion

1. Factorial         2. Prime number           3. Fibonacci series  
4. GCD               5. Palindrome             6. Reverse string
7. LCM               8. Multiplication         9. Sum of digits
10. Find power       11. Reverse number       12. Sum of n numbers 13. Binary search    14. Decimal to binary      15.Matrix multiplication    
Print different Shapes

Sum of Series

4. A.P.                5. G.P.                6. H.P.
Area and volume

1. Circle       2. Triangle       3. Equilateral triangle         4.Rectangle     5. Trapezium      6. Parallelogram  7. Right angled triangle          8. Rhombus 
9. Cylinder     10. Cube          11. Cuboids          12. Cone        13. Sphere        14. Perimeters

Find Size of data types (Without using sizeof)

1. int         2. double         3. struct              4. union

Operation on very large number (Beyond long int)

1. Multiplication          2. Division          3. Modular           5. Factorial of 1000       6. Power             7. More c codes

Miscellaneous

1. C++ programs            2. Java programs

107 comments:

  1. please write the program for follwing
    if u enter number between 2 to 9 it will display like
    5=1,1,1,1,1
    5=1,1,1,2
    5=1,1,3
    5=1,4
    5=2,1,1,1
    5=2,2,1
    5=3,1,1
    5=4,1

    ReplyDelete
    Replies
    1. your query is inappropriate..

      5=1,1,1,1,1
      5=1,1,1,2
      5=1,1,3
      5=1,4
      5=2,1,1,1
      -till here it is acceptable..
      but later on, it should be like this..
      5=2,1,2
      5=2,3
      5=3,1,1
      5=3,2
      5=4,1

      Delete
    2. and for the output..

      5=1,1,1,1,1
      5=1,1,1,2
      5=1,1,3
      5=1,4
      5=2,1,1,1
      5=2,1,2
      5=2,3
      5=3,1,1
      5=3,2
      5=4,1

      the code is..


      #include

      int n=5;
      int a[5]={1,1,1,1,1};
      int ar[5];

      void disp()
      {
      int sum=0,i;
      printf("%d=",n);
      for(i=0;sum<n;i++)
      {
      printf("%d,",ar[i]);
      sum+=ar[i];
      }
      printf("\n");
      }



      void clublast()
      {
      int i;
      for(i=0;i<n;i++)
      ar[i]=a[i];

      for(i=0;i<n-1;i++)
      {
      if(ar[n-i-1]==0) continue;
      disp();
      ar[n-i-2]+=ar[n-i-1];
      }
      }



      void main()
      {
      int i;
      for(i=0;a[0]<n;i++)
      {
      clublast();
      a[0]++;
      a[n-i-1]=0;
      }

      getchar();
      }

      Delete
  2. good.. very useful

    ReplyDelete
  3. please write a program for following:
    write a program to delete all vowels from a sentence.Assume that the sentence is not more than 80 characters long.

    ReplyDelete
    Replies
    1. #include

      int main()
      {
      //code
      char str[20],fnl[20];
      int i,j;
      printf("Enter the string: ");
      scanf("%[^\n]s",str);

      for(i=0,j=0;i<strlen(str);i++)
      {
      if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u')
      {
      continue;
      }
      fnl[j++]=str[i];
      }
      printf("%s",fnl);
      return 0;
      }

      Delete
  4. please write a program for following:
    write a program which will read a line and squeeze out all blanks from it and output the line with no blanks.

    ReplyDelete
    Replies
    1. #include<stdio.h>

      int main(){

      char str[100];
      char squeeze[100];
      int i=0,j=0;

      scanf("%[^\n]",str);

      while(str[i] != '\0'){

      if(str[i] != 32)
      squeeze[j++] = str[i]; i++;

      }

      squeeze[j] = '\0';

      printf("%s",squeeze);

      return 0;

      }

      Sample Output:
      c programming lanaguage
      cprogramminglanaguage

      Delete
    2. pllz write a program in c which multiply two square matrices using divide and conqure algorithm

      Delete
  5. i want c program conects to sql server displays global time zone??

    ReplyDelete
  6. Qlxchange : Ha detto: interessante

    ReplyDelete
  7. hi i want programme on combination example "ENGINEER" possible combinations on this string using recursion function
    thanks

    ReplyDelete
  8. Your site is very good.

    ReplyDelete
  9. nice article...
    i can learn my knowledge from this site...thanks for sharing this excellent site...i hope keep writing...

    ReplyDelete
  10. Really helpful.Thanks a lot! Never knew selfless people like this exist. Thanks a ton!

    ReplyDelete
  11. what will be output of this please solve


    #include

    main()

    {

    int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };

    int *p,*q;

    p=&a[2][2][2];

    *q=***a;

    printf("%d----%d",*p,*q);

    }

    ReplyDelete
    Replies
    1. pllz write a program in c which multiply two square matrices using divide and conqure algorithm

      Delete
  12. Write a program to input 10 integers and sort them. Use a menu system to determine
    whether the sort should be ascending or descending order. The process should continue
    till the user desires to exit.

    ReplyDelete
  13. wap to find the height of the wall if the height of the ladder and the inclination of the ladder from the ground is given by the user.
    how to solve the above question in c.

    ReplyDelete
    Replies
    1. #include<stdio.h>
      #include <math.h>

      #define PI 3.141592653589793238462643383

      int main(){

      float h = 10;
      double inclation = PI/6;
      float p;

      p = h * sin(inclation );

      printf("Height of wall %lf",p);

      return 0;

      }

      Delete
  14. Given two arrays of size n, exactly one number is missing in the second array of the elements of first array. Write a function to return the missing number.

    ReplyDelete
    Replies
    1. #include<stdio.h>

      int main(){

      int arr1[5]= {1,2,3,4,5};
      int arr2[5]= {3,1,5,2};
      int i,j;
      int flag;

      for(i=0;i<5;i++){

      flag =0;

      for(j=0;j<5;j++){

      if(arr1[i] == arr2[j]){

      flag = 1;
      break;

      }
      }

      if(flag ==0){

      printf("Missing element in arr2 is: %d",arr1[i]);
      break;

      }
      }

      return 0;

      }

      Delete
    2. /******************
      Using one for loop and no need of comparison of numbers one by one.
      ******************/

      #define SIZE 5
      int main()
      {
      int arr1[SIZE] = {1,2,3,4,5};
      int arr2[SIZE-1] = {3,1,5,2};

      int sum1 = 0, sum2 = 0,i;

      for(i=0; i < SIZE-1; i++)
      {
      sum1 = sum1 + arr1[i];
      sum2 = sum2 + arr2[i];
      }
      sum1 = sum1 + arr1[i];

      printf("Missing number : %d \n", sum1 - sum2);
      }

      Delete
  15. hey every body ...
    ive recently found this site ... its very awesome ...

    iam trying to sort a 2-dimensional array (in ascending order) based on the sum of each row.

    this is an example;
    input
    1 5 7
    2 4 3
    1 3 2
    7 0 1
    ........
    output
    1 3 2
    7 0 1
    2 4 3
    1 5 7

    can anybody help me with this ...

    ReplyDelete
    Replies
    1. #include<stdio.h>

      int main(){

      int arr[4][3]= {{1,5,7},{2,4,3},{1,3,2},{7,0,1}};
      int temp[1][3];
      int i,j,l=4;

      for(i=0;i<l;i++){
      for(j=i+1;j<l;j++){

      if(arr[i][0] + arr[i][1] + arr[i][2] > arr[j][0] + arr[j][1] + arr[j][2]){

      temp[0][0]=arr[i][0];
      temp[0][1]=arr[i][1];
      temp[0][2]=arr[i][2];

      arr[i][0]=arr[j][0];
      arr[i][1]=arr[j][1];
      arr[i][2]=arr[j][2];

      arr[j][0]=temp[0][0];
      arr[j][1]=temp[0][1];
      arr[j][2]=temp[0][2];
      }
      }
      }

      for(i=0;i<l;i++){
      printf("%d %d %d \n",arr[i][0],arr[i][1],arr[i][2]);
      }

      return 0;
      }

      Delete
  16. Dear Mr. ritesh kumar,

    thank you very much. it was a great help. i really appreciate

    ReplyDelete
  17. please write a program in c to find complement of a set

    ReplyDelete
  18. Thanks for easy C tutorials.

    ReplyDelete
  19. hi ... can you write a program in C to find determinant of a Eigenvalue problem 2X2 & 3X3... please ... please.... I need It very fast ... thank you.

    ReplyDelete
  20. if u introduce about hailhoods series amd dice it would be nice

    ReplyDelete
  21. hi ... can you Write a program to find the area of a circle (2*pi*R) where R=Radius. (using functions)

    ReplyDelete
  22. I found this very informative thank you

    ReplyDelete
  23. best site ever

    ReplyDelete
  24. thank u very much.
    thank u thank u
    thank u.

    ReplyDelete
  25. please make a program for finding sinx using following series
    sinx = x - x^3/3! + x^5/5! - x^7/7! + .... + x^n/n!

    ReplyDelete
  26. Can u make program for collecting the students personal info and store it in a files by allocating memory dynamically..... pls

    ReplyDelete
  27. write a program to create a file of structure.the file should have all the particuler of citizen who pay income tax like permanent account number,name,address,tax number and year.

    ReplyDelete
  28. please add the examples for structures and link list or suggest any link... and please ex plane union,type def .

    ReplyDelete
  29. please write an algorithm for swap sorting that uses the minimum number of swaps to sort a circular permutation

    ReplyDelete
  30. Write a code that determines the BER for a simple detector for a digital communication
    system. A digital communication system can be described as follows: a transmitter sends a
    sequence of 0’s and 1’s to a designated receiver. Due to non­ideal wireless transmission, the
    transmitted sequence is erroneously received due to the presence of noise. The noise is a
    random signal that is added to each bit of the transmitted sequence and changes its value at
    each bit. For example, you can send the following sequence 1 0 1 0 1 0 and the noise value at
    each bit happens to be something like 0.2 0.4 ­0.3 0.3 ­0.5 ­0.3 so the received signla will be like
    1.2 0.4 0.7 0.3 0.5 ­0.3. In order to detect the sequence, a receiver compares the received value
    to a threshold of 0.5. If the received signal is greater than 0.5, a bit is decoded as 1, else it is
    decoded as 0. You are required to generate a sequence of bits, add noise to each bit and
    calculate the Bit Error Rate (BER) which is   number of errors in the sequence/length of the
    sequence. Noise generation could be done by the function rand you have to repeat the
    transmission many times and find the average error rate. For example: a transmission of [ 1 0 0
    0 1 1 0 0 0 0], and noise of [0 0.3 0.4 0.6 0 0 0.1 0.2 ­0.3 ­0.2] will give one error at the 4th
    element, i.e ber 1/10.
    i cant do it plz help me :)

    ReplyDelete
  31. devlop a structure 'formula-one'. member should include driver's name lapnumber along with completion time for each lap,age of driver. devlop the function getdata() to get data from the user. showdata() to display the data of particular driver and average()to display the average laptime of each driver.use main function to call these functions. please solve this question.

    ReplyDelete
  32. Program to multiply 2 numbers without using multiplication symbol(Hint: add first number the number of times the second number)


    give me the answer

    ReplyDelete
  33. post prog in c and explanation

    implementaion for stack ,queue
    conversion of infix to postfix

    ReplyDelete
  34. Hi bro, i was just trying to make a LUDO game for C, i just made the board of it, and the game is for just 2 players, just wondering, how can i create a function that moves the tokens, watch it out
    #include
    #include
    #include
    #define F2 2//Codigo de ficha 2 para que no cambie de valor nunca y se mantenga el caracter especial cara RELLENA
    #define F1 1 //Codigo de ficha 1 para que no cambie de valor nunca y se mantenga el caracter especial cara VACIA
    #define B2 219 //COdigo para la base de la ficha 2, cuadrado RELLENO
    #define B1 176 //COdigo para la base de la ficha 1, cuadrado VACIO
    #define D123 254 //Codigo para que aparezcan dados imaginarios, es un cuadrado relleno con codigo ascii 254

    void movf1(int *ptr){



    int main(){
    /*COmenzamos el tablero desde arriba*/
    /*fila11, a21 caracter especial de comienzo de partida*/
    int a19=1, a20=1, a21=31;
    printf("0 0 0 0 %i-%i-%c 0 0 0 0\n", a19, a20, a21);
    /*fila 10, f4 caracter especial de cuadrado, aplicacion de la constante F2*/
    int a18=1, f1=B2, a22=1, c1=F2, c2=F2;
    printf("0 0 0 0 %i %c %i 0 %c %c 0\n", a18, f1, a22, c1, c2);
    /*fila 9, f3 caracter especial cuadrado, aplicacion de la constante F2*/
    int a17=1, f2=B2, a23=1, c3=F2, c4=F2;
    printf("0 0 0 0 %i %c %i 0 %c %c 0\n", a17, f2, a23, c3, c4);
    /*fila 8*/
    int a16=1, f3=B2, a24=1;
    printf("0 0 0 0 %i %c %i 0 0 0 0\n", a16, f3, a24);
    /*fila 7*/
    int a11=1, a12=1, a13=1, a14=1, a15=1, f4=B2, a25=1, a26=1, a27=1, a28=1, a29=1;
    printf("%i-%i-%i-%i-%i %c %i-%i-%i-%i-%i\n", a11, a12, a13, a14, a15, f4, a25, a26, a27, a28, a29);
    /*fila 6*/
    int a10=1, a30=1;
    printf("%i 0 0 0 0 0 0 0 0 0 %i\n", a10, a30);
    /*fila 5*/
    int a9=1, a8=1, a7=1, a6=1, a5=1, e4=B1, a35=1, a34=1, a33=1, a32=1, a31=1;
    printf("%i-%i-%i-%i-%i %c %i-%i-%i-%i-%i\n", a9, a8, a7, a6, a5, e4, a35, a34, a33, a32, a31);
    /*fila 4, caracter especial en e3 base blanca codigo ascii 176*/
    int a4=1, e3=B1, a36=1;
    printf("0 0 0 0 %i %c %i 0 0 0 0\n", a4, e3, a36);
    /*fila 3*/
    int b1=F1, b2=F1, a3=1, e2=B1, a37=1, d1=D123, d2=D123, d3=D123;
    printf("0 %c %c 0 %i %c %i %c %c %c 0\n", b1, b2, a3, e2, a37, d1, d2, d3);
    /*fila 2*/
    int b3=F1, b4=F1, a2=1, e1=B1, a38=1;
    printf("0 %c %c 0 %i %c %i 0 0 0 0\n", b3, b4, a2, e1, a38);
    /*fila 1, a1 inicio de partida caracter especial*/
    int a1=30, a40=1, a39=1;
    printf("0 0 0 0 %c %i %i 0 0 0 0", a1, a40, a39);

    /*DEFINIENDO 56 Punteros, en las ubicaciones que variaran*/
    //fila1
    int *z1=&a1;
    int *z40=&a40;
    int *z39=&a39;
    //FILA 2
    int *y3=&b3;
    int *y4=&b4;
    int *z2=&a2;
    int *v1=&e1;
    int *z38=&a38;
    //fila 3
    int *y1=&b1;
    int *y2=&b2;
    int *z3=&a3;
    int *v2=&e2;
    int *z37=&a37;
    //fila4
    int *z4=&a4;
    int *v3=&e3;
    int *z36=&a36;
    //fila 5
    int *z9=&a9;
    int *z8=&a8;
    int *z7=&a7;
    int *z6=&a6;
    int *z5=&a5;
    int *v4=&e4;
    int *z35=&a35;
    int *z34=&a34;
    int *z33=&a33;
    int *z32=&a32;
    int *z31=&a31;
    //fila 6
    int *z10=&a10;
    int *z30=&a30;
    //fila 7
    int *z11=&a11;
    int *z12=&a12;
    int *z13=&a13;
    int *z14=&a14;
    int *z15=&a15;
    int *u4=&f4;
    int *z25=&a25;
    int *z26=&a26;
    int *z27=&a27;
    int *z28=&a28;
    int *z29=&a29;
    //fila 8
    int *z16=&a16;
    int *u3=&f3;
    int *z24=&a24;
    //fila 9
    int *z17=&a17;
    int *u2=&f2;
    int *z23=&a23;
    int *x3=&c3;
    int *x4=&c4;
    //fila 10
    int *z18=&a18;
    int *u1=&f1;
    int *z22=&a22;
    int *x1=&c1;
    int *x2=&c2;
    //fila 11
    int *z19=&a19;
    int *z20=&a20;
    int *z21=&a21;



    getch();
    return 0;
    }

    ReplyDelete
  35. Very very usefull and good site

    thank you very much

    ReplyDelete
  36. Can you send me the practical usages of NULL POINTERS?????

    ReplyDelete
  37. I have a doubt... is it true that a++ is faster than a=a+1 ?

    ReplyDelete
    Replies
    1. Abhisek go through this link
      http://www.cquestions.com/2010/03/why-i-is-faster-than-ii1-in-c.html

      Delete
  38. Q. Significance of primility testing in formulation of public key cryptography algorithm.
    can any one provide some agenda what to do and how to do this assignment?

    ReplyDelete
  39. hey please solve my question:
    write a program to find out how many tiles of 25 sq.cms can be fitted in a plot of 100 sq. mtrs

    ReplyDelete
  40. hey please solve my question:
    write a program to find out how many tiles of 25 sq.cms can be fitted in a plot of 100 sq. mtrs
    if u know thee answer please mail me at rohanvgosalia@gmail.com

    ReplyDelete
  41. can you tell me how i write a c programme a given number is prime or not

    ReplyDelete
  42. Please help me, i want to implement a prefix expression in c - linux using fork and pipe without files and stacks,
    such as: ( + ( + 8 9) ( * 7 5)) = 52
    please the deadlock in 27/11/13

    ReplyDelete
  43. create a quee programfor following function using link list
    a.create
    b.display
    c.print left to right
    d.print right to left
    e.replace
    f.count no of node

    ReplyDelete
  44. sir this is excellent.can u tell me any good site of data structure

    ReplyDelete
  45. Write a program which asks user name of a text file. Once the user enters the name,
    your program will try to open it. If there is no such file (i.e. the user enters a wrong file
    name), your program will not crash and warn the user with an error message.
    Once the text file is opened successfully, your program will provide the following
    functionalities in a menu:
    1. Find: In selection of this choice, your program will ask the user a word. Once
    the user enters the word, then the program will search for this word in the text
    file and returns the number of occurrences in the file.
    2. Find & Replace: In addition to the previous option, your program will ask two
    words the user (word1 and word2). Then the program will search the word1 in
    the file and replaces them with word2. In this option, make sure that you open
    the file for read and write enable.

    hİ , Can you help me please , HOW DO I DO THAT ?

    ReplyDelete
  46. Can any one able to solve following:

    Define a structure called cricket with player name, team name, and batting average.
    Declare an array of player with 5 elements. Write a program to read the information
    about all the 5 players and print a team-wise list containing names of players with
    their batting average.

    ReplyDelete
    Replies
    1. #include

      int main()
      {
      //code
      int i;
      struct cricket
      {
      char tname[20]; //Team name
      float batavg; //Batting avg
      };
      struct cricket cricketers[5];

      for(i=0;i<5;i++)
      {
      scanf("%s %f",&cricketers[i].tname,&cricketers[i].batavg);
      }
      printf("%s",cricketers[2].tname);
      return 0;
      }

      Delete
  47. i have a problem in java program .can anybody solve it
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class ComboxDemo extends Applet implements ItemListener
    {
    int i,pr;
    String msg="";
    Choice two,three,op;
    public void init()
    {
    two=new Choice();
    three=new Choice();
    op=new Choice();
    for(i=1;i<=10;i++)
    {
    pr=2*i;
    two.add(""+pr);
    }
    for(i=1;i<=10;i++)
    {
    pr=3*i;
    three.add(""+pr);
    }
    op.add("+");
    op.add("-");
    op.add("*");
    op.add("%");
    add(two);
    add(three);
    add(op);
    two.addItemListener(this);
    three.addItemListener(this);
    op.addItemListener(this);
    }
    public void itemStateChanged(ItemEvent ie)
    {
    repaint();
    }
    public void paint(Graphics g)
    {
    msg="first n0.";
    msg+=two.getSelectedItem();
    g.drawString(msg,6,100);
    msg="second no :";
    msg+=three.getSelectedItem();
    g.drawString(msg,6,120);
    msg="operand ";
    msg+=op.getSelectedItem();
    g.drawString(msg,6,140);
    msg="result";
    msg+=two+" "+three;
    g.drawString(msg,6,160);
    }
    }
    in the above program i want to perform operation between tabels of 2 and 3.for thi what ihave to add in the program

    ReplyDelete
  48. Given The Positive Integer A,b And M With M>1 Find A^b Mod M Using C Program,, i need your help..

    ReplyDelete
  49. //how value of A=20
    # define SQR(X) (X*X)
    void main()
    {
    int a;
    a = SQR(6+2);
    printf(“\n%d”, a);
    }

    ReplyDelete
    Replies
    1. As per MACRO 6+2 is replaces as (6+2*6+2). As per priority multiplication takes first. Then it becomes (6+12+2). The it becomes 20

      Delete
  50. Admin pls write a c program for finding the given number is odd r even without modulo operator..

    ReplyDelete
  51. Please help write a code to program inverse laplase of a function.

    ReplyDelete
  52. It is very useful for me

    ReplyDelete
  53. write a program to print the value of number in words when number entered is in the range of 0 to 999

    ReplyDelete
    Replies
    1. #include

      int main() {
      //code
      int n,r[3],i=0;
      char s[10][6]={"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};

      printf("Enter the number: ");
      scanf("%d",&n);

      while(n)
      {
      r[i++]=n%10;
      n=n/10;
      }

      while(i)
      {
      printf("%s ",s[r[--i]]);
      }
      return 0;
      }

      Delete
  54. John is standing at point (a,b) in an infinite 2D grid. He wants to know if he can reach point (x,y) or not. The only operation he can do is to move to point (a+b,b), (a,a+b), (a-b,b), or (a,a-b) from some point (a,b). It is given that he can move to any point on this 2D grid,i.e., the points having positive or negative X(or Y) co-ordinates.
    Tell John whether he can reach (x,y) or not.

    ReplyDelete
  55. Having looked at the first test, it is rife with undefined behaviour. Asking what the output would be implies that it is defined, it is not. Thinking you know C if you give any answer besides undefined behaviour means you do not in fact know the language. There should be an answer available like "You will be demoted or fired if you are the author of this code". It could replace one of the answers which say what a particular compiler might output - a diagnostic for multiple updates of a variable without a sequence point isn't required, so the programs may well compile. They are not obliged to produce any particular output and the output could well differ depending on the compiler, its version and the optimisation level used during the compile.
    Questions like these should not appear in this test, as it suggests that such prormaming is acceptable - it is not.

    ReplyDelete
  56. Write a program that adds up two 4x4 arrays and stores the sum in third array.??????
    Pleas solve it Question in c++????

    ReplyDelete
    Replies
    1. #include

      int main() {

      int one[4][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
      int two[4][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
      int res[4][4],i,j;

      for(i=0;i<4;i++)
      {
      for(j=0;j<4;j++)
      {
      res[i][j]=one[i][j]+two[i][j];
      }
      }

      for(i=0;i<4;i++)
      {
      for(j=0;j<4;j++)
      {
      printf("%4d",res[i][j]);
      }
      printf("\n");
      }
      return 0;
      }

      Delete
  57. what is prototype declaration?

    ReplyDelete
    Replies
    1. We declare a function like int AddTwoInt(int,int) this is prototype

      Delete
  58. I need help in this program:
    In c language:

    1 - Create a text file containing alphabetic characters , numbers, and punctuation characters .
    2. calculate the frequency of a particular word can be replaced by another of the same length.
    Example ( tall instead of long )
    I urgently need to Answer

    ReplyDelete
    Replies
    1. this may help you

      #include
      #include
      int main()
      {
      char str1[100]="replace long by tall";
      char str2[20];
      char str3[20];
      printf("Enter word which is you want to remove");
      gets(str3);
      printf("Enter a word by which you want to replace word");
      gets(str2);


      int n1=strlen(str1);
      int n2=strlen(str2);
      int n3=strlen(str3);
      int i=0;
      while(i<n1)
      {
      int j=0;
      int k=i;
      while(j<n2)
      {
      if(str1[k]==str3[j])
      {
      k++;
      j++;
      }
      else
      {
      break;
      }

      }
      if(j==n2)
      {
      int l=0;
      for(l=0;l<n2;l++)
      {
      str1[i]=str2[l];
      i++;
      }
      }
      i++;


      }
      printf("%s",str1);
      return 0;
      }

      Delete
    2. #include
      #include
      int main()
      {
      char str1[100]="replace long by tall";
      char str2[20];
      char str3[20];
      printf("Enter word which is you want to remove");
      gets(str3);
      printf("Enter a word by which you want to replace word");
      gets(str2);


      int n1=strlen(str1);
      int n2=strlen(str2);
      int n3=strlen(str3);
      int i=0;
      while(i<n1)
      {
      int j=0;
      int k=i;
      while(j<n2)
      {
      if(str1[k]==str3[j])
      {
      k++;
      j++;
      }
      else
      {
      break;
      }

      }
      if(j==n2)
      {
      int l=0;
      for(l=0;l<n2;l++)
      {
      str1[i]=str2[l];
      i++;
      }
      }
      i++;


      }
      printf("%s",str1);
      return 0;
      }

      Delete
  59. Hi. I have a program that shows a matrix , sorts the numbers in the rows in ascending order. I want to modify it so it : (1)sorts the numbers in the rows in descending order and (2) to count how many times the digit ''2'' could be found in the matrix.
    Can anybody advise me how to do it ?
    Thanks in advance :)
    #include



    void main()

    {

    static int array1[10][10], array2[10][10];

    int i, j, k, a, m, n, count=0;



    printf("Enter the order of the matrix \n");

    scanf("%d %d", &m, &n);

    printf("Enter co-efficients of the matrix \n");

    for (i = 0; i < m; ++i)

    {

    for (j = 0; j < n; ++j)

    {

    scanf("%d", &array1[i][j]);

    array2[i][j] = array1[i][j];

    }

    }

    printf("The given matrix is \n");

    for (i = 0; i < m; ++i)

    {

    for (j = 0; j < n; ++j)

    {

    printf(" %d", array1[i][j]);

    }

    printf("\n");

    }

    printf("After arranging rows in ascending order\n");

    for (i = 0; i < m; ++i)

    {

    for (j = 0; j < n; ++j)

    {

    for (k =(j + 1); k < n; ++k)

    {

    if (array1[i][j] > array1[i][k])

    {

    a = array1[i][j];

    array1[i][j] = array1[i][k];

    array1[i][k] = a;

    }

    }

    }

    }

    for (i = 0; i < m; ++i)

    {

    for (j = 0; j < n; ++j)

    {

    printf(" %d", array1[i][j]);

    }

    printf("\n");

    }




    }

    ReplyDelete
  60. Hi., Try this Program!!
    Counting Factorial Numbers

    Due on 2015-08-04, 23:59 IST


    A number F is a factorial number if there exists some integer I>=0 such that F=I! (that is, F is factorial of I). Examples of factorial numbers are : 1,2,6,24,120,….

    Write a program that takes as input two long integers n and m where 0≤n≤m. The program prints an integer k, where k is the count of factorial numbers in the closed interval [n,m].

    Examples:
    Input: 0 1
    Output: 1
    //Reason (Do not print) : Only factorial number is 1

    Input: 12 122
    Output: 2
    // Reason: factorial numbers are 24, 120

    Input: 2 720
    Output: 5
    // Factorial numbers are: 2, 6, 24, 120, 720


    Note:
    1. The interval is closed, i.e., n and m are included in count if they are factorial numbers.
    2. Ignore Presentation Errors for this problem.

    ReplyDelete
  61. I have 8 question any expert here who can solve if any one then plzz replyy i need answer as soon as possible

    ReplyDelete
  62. y can,t we use getint() or getchar() or getfloat() instead of getch()

    ReplyDelete
  63. Write a program to do linear search for an integer number in
    an array of 20 distinct numbers. The program should return the
    location of an element if the number found in the array.

    ReplyDelete
  64. your blog is very helpful for me for learn objective c. Thank you so much for sharing.

    ReplyDelete
  65. Good day everyone, can anyone answer my question? i am doing my study and i want to print the output in the file but only 0's appear in the file, this is the code

    // Program to print all combination of size r in an array of size n
    #include
    #define MAX 500000
    void combinationUtil(int arr[],int n,int r,int index,int data[],int i);


    /* arr[] ---> Input Array
    n ---> Size of input array
    r ---> Size of a combination to be printed
    index ---> Current index in data[]
    data[] ---> Temporary array to store current combination
    i ---> index of current element in arr[] */
    void combinationUtil(int arr[], int n, int r, int index, int data[], int i)
    {
    int j,total=0;
    FILE *fin;
    fin = fopen("filethesis.txt", "a+");
    // Current cobination is ready, print it
    if(index == r)
    {
    for(j=0; j= n)
    return;

    // current is included, put next at next location
    data[index] = arr[i];
    combinationUtil(arr, n, r, index+1, data, i+1);

    // current is excluded, replace it with next (Note that
    // i+1 is passed, but index is not changed)
    combinationUtil(arr, n, r, index, data, i+1);

    }

    // Driver program to test above functions
    int main()
    { int data[MAX];
    int arr[] = {1, 2, 3, 4, 5,6,7,8,9,10};
    int r = 5;
    int n = sizeof(arr)/sizeof(arr[0]);
    //printCombination(arr, n, r);
    combinationUtil(arr,n,r,0,data,0);

    return 0;
    }

    \\suggestions and comments are highly appreciated.

    ReplyDelete
  66. 1,5,9,13,29,41,77,....,N
    Can anyone give the logic of the above series

    ReplyDelete
  67. Hi guyz can someone assist me in this c program quiz
    (i) Write a function that returns the larger of two floating point numbers.
    (ii) Write a program to convert Kenya shillings to USA dollars, when the user inputs the amount in Kenya shillings. (Let Kshs. 78.00 = 1 US Dollar)
    (iii). Write a program that asks for your name and then inputs your first, middle and last names. Have the program read no more than 20 characters for each part of your name. Finally, have the program redisplay your full name

    ReplyDelete
  68. 1.2.4+2.3.6+3.4.8+.....10.11.22

    ReplyDelete
  69. give me the answer
    write a c program to accept sides of triangle and calculate the perimeter of triangle

    ReplyDelete
  70. Hi - trying to do this one but keep getting errors - I would be really grateful for your help please.

    Write a menu-driven program that allows the user to fill an array, query the array, and print the array. The menu and an explanation of each option is shown below



    Select one of the following options:
    F. Fill the array with a random number series.
    P. Print the array.
    Q. Query the array.
    Z. Terminate the program.


    Thank you so much in advance

    ReplyDelete
  71. Write a program which takes any decimal number (b/w 1 and 31) and convert into binary and octal form

    ReplyDelete

  72. Y
    ou
    can use any logic and any language.
    Must explain
    your
    answers properly.
    please help me to solve this question
    FCFS(First Come First Served)
    1.
    Indian Rupee system had following denominations 100p,50p,25p,20p,10p,5p and 1p. Given an
    amount in Rs. (Ex, Rs.4.67) Figure out minimum number of coins needed to get
    specified
    amount. Write function name as minCoins( ) which accept float value as input and print out
    denominations and count.
    2.
    If you start with Rs.
    1 and, with each move,
    you can either do
    uble your money or add another
    Rs.
    1, what is the smallest number of moves you
    have to make to get to exactly Rs.
    200
    , Rs.300,
    Rs. 400,
    Et
    c
    ?
    Write a program to
    calculate the moves.

    ReplyDelete
  73. please any one help me to solve this question


    FCFS(First Come First Served)
    1.
    Indian Rupee system had following denominations 100p,50p,25p,20p,10p,5p and 1p. Given an
    amount in Rs. (Ex, Rs.4.67) Figure out minimum number of coins needed to get
    specified
    amount. Write function name as minCoins( ) which accept float value as input and print out
    denominations and count.
    2.
    If you start with Rs.
    1 and, with each move,
    you can either do
    uble your money or add another
    Rs.
    1, what is the smallest number of moves you
    have to make to get to exactly Rs.
    200
    , Rs.300,
    Rs. 400,
    Et
    c
    ?
    Write a program to
    calculate the moves.

    ReplyDelete
  74. please any one help me to solve this question


    FCFS(First Come First Served)
    1.
    Indian Rupee system had following denominations 100p,50p,25p,20p,10p,5p and 1p. Given an
    amount in Rs. (Ex, Rs.4.67) Figure out minimum number of coins needed to get
    specified
    amount. Write function name as minCoins( ) which accept float value as input and print out
    denominations and count.
    2.
    If you start with Rs.
    1 and, with each move,
    you can either do
    uble your money or add another
    Rs.
    1, what is the smallest number of moves you
    have to make to get to exactly Rs.
    200
    , Rs.300,
    Rs. 400,
    Et
    c
    ?
    Write a program to
    calculate the moves.

    ReplyDelete
  75. use insertion sort for sorting a 5-element array in ascending order

    ReplyDelete
  76. write a program to accept 2 numbers and tell whether the product of the two numbers is greater than or equal to 1000

    ReplyDelete
  77. Code 1:
    1. Write a program to generate the Fibonacci series in c
    2. Write a program to print Fibonacci series in c
    3. Basic c programs Fibonacci series
    4. How to print Fibonacci series in c
    5. How to find Fibonacci series in c programming
    6. Fibonacci series in c using for loop

    #include
    int main(){
    int k,r;
    long int i=0l,j=1,f;

    //Taking maximum numbers form user
    printf("Enter the number range:");
    scanf("%d",&r);

    printf("FIBONACCI SERIES: ");
    printf("%ld %ld",i,j); //printing firts two values.

    for(k=2;k
    int main(){

    int i,range;
    long int arr[40];

    printf("Enter the number range: ");
    scanf("%d",&range);

    arr[0]=0;
    arr[1]=1;

    for(i=2;i
    int main(){
    int k=2,r;
    long int i=0l,j=1,f;

    printf("Enter the number range:");
    scanf("%d",&r);

    printf("Fibonacci series is: %ld %ld",i,j);

    while(k
    int main(){
    int k,r;
    long int i=0,j=1,f;
    long int sum = 1;

    printf("Enter the number range: ");
    scanf("%d",&r);

    for(k=2;k<r;k++){
    f=i+j;
    i=j;
    j=f;
    sum = sum + j;
    }

    printf("Sum of Fibonacci series is: %ld",sum);

    return 0;
    }

    Sample output:
    Enter the number range: 4
    Sum of Fibonacci series is: 4

    Algorithm:

    What is Fibonacci series?

    Logic of Fibonacci series

    Definition of Fibonacci numbers:


    We assume first two Fibonacci are 0 and 1
    A series of numbers in which each sequent number is sum of its two previous numbers is known as Fibonacci series and each numbers are called Fibonacci numbers. So Fibonacci numbers is

    Algorithm for Fibonacci series

    Fn = Fn-2 + Fn-1

    Example of Fibonacci series:

    0 , 1 ,1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 ...

    5 is Fibonacci number since sum of its two previous number i.e. 2 and 3 is 5
    8 is Fibonacci number since sum of its two previous number i.e. 3 and 5 is 8 and so on.

    ReplyDelete
  78. help me to write a c program that lists Fibonacci numbers between 0 and 30,and then find the sum of all.

    ReplyDelete
  79. so i need anyone who knows this to help me getting the answer of this question above.

    ReplyDelete
  80. C Programming Tips and Tricks...
    https://youtu.be/TBKVuM9W8RM

    ReplyDelete
  81. C Programming Tips and Tricks...
    https://youtu.be/TBKVuM9W8RM

    ReplyDelete
  82. C Programming Tips And Tricks...

    Vist This Link..
    https://youtu.be/TBKVuM9W8RM

    ReplyDelete
  83. Write a program that will read the value of x and evaluate the following function
    y ={(1 for x>0, 0 for x=0, -1 for x<0}
    using
    (a) nested if statements,
    (b) else if statements, and
    (c) conditional operator ? :

    ReplyDelete
  84. plz can someone help me , write a program that reades measured values of ressistance in several times , the number of measurments is defined by the user up to 100 , the program need to diplay the average tha maximal measuered value and the standard deviation

    ReplyDelete