Home » Aptitude Questions and Answers » C Aptitude Questions and Answers

C programming Cast Type Aptitude Questions and Answers

This section contains Aptitude Questions and Answers on Cast Typing, Basically in C programming language there are two types of cast type - Implicit and Explicit.

List of Cast Type Aptitude Questions and Answers

1) What will be the output of following program ?
#include <stdio.h>
 
int main()
{
    int x=65;
    const unsigned char c=(int)x;
     
    printf("%c\n",c);
 
    return 0;
}
  1. Error
  2. 65
  3. A
  4. Null

2) What will be the output of following program ?
#include <stdio.h>
 
int main()
{
    int x=2.3;
    const char c1=(float)x;
    const char c2=(int)x;
     
    printf("%d,%d\n",c1,c2);
 
    return 0;
}
  1. Error
  2. 2.3,2
  3. 2.300000,2
  4. 2,2


3) What will be the output of following program ?
#include <stdio.h>
 
int main()
{
    char *text="Hi Babs.";
     
    char x=(char)(text[3]);
     
    printf("%c\n",x);
     
    return 0;
}
  1. Garbage
  2. B
  3. Error
  4. Null

4) What will be the output of following program (on 32 bit compiler)?
#include <stdio.h>
 
int main()
{
    int x=65;
    const unsigned char c=(int)x;
     
    printf("%c\n",c);
 
    return 0;
}
  1. 65.00
  2. 65
  3. A
  4. Error






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.