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. 120.00
  2. 120
  3. 120.000000
  4. Error



5) 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






Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.




Comments and Discussions





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 (2015-2018), Some rights reserved.




close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.