Which of the following would constitute a narrowing conversion in C++?
Converting a char into an int. |
||
Converting an int into a short. |
||
Converting a float into a double. |
||
Converting a char into an int*. |
Narrowing means assigning value to a variable not capable of holding it. For eg . assigning numeric to other numeric not capable of holding it because of less size.
for eg.
converting int to short. short has less size, so its not capable of holding an int value. this is called narrowing.
so b) is correct
Which of the following would constitute a narrowing conversion in C++? Converting a char into an...
2. Give the minimum size of each of the following C++ types, assuming that char values occupy one byte, short values occupy two bytes, int and float values occupy four bytes, double and long values occupy eight bytes, and pointers occupy four bytes. a) union u type ( double a[3]; int *b; char c[10] b) struct s1type float *d [2]; long e[4] char f[6] short *gi c) struct s2 type ( s1_type s; u type u [2]; int *h[3]; short...
Give the minimum size of each of the following C data structures, assuming that char values occupy byte, int and float values occupy four bytes, double values occupy eight bytes, and pointers occupy bytes. (a) char str[] = "Curly": (b) double *a[4][4]: (c) char *str[3] = {"Moe", "Larry", "Curly"}: (Include the space occupied by the string literals in your answer.) (d) union { int a: char b: float c[4]: }u: (e) struct { int a: char b: float c[4]: }s:...
Which of the following conversion factors, as written, would be used when converting a measurement in miles per hour to meters per second? Choose all that apply. (1.61 km / 1 mi) (60 s / 1 min) (60 min / 1 hr) (1000 m / 1 km) None of these converswion factors would be used.
S. Modułus operator can operate upon A. double B、 float C. char D. int E. C and D
Create a UNIX makefile for the following C program: //convert.c char toUpper(char c){ if(c>='a' && c<='z') return c-32; return c; } //converting sentance to upper void convertSentence(char *sentence){ int i=0; while(sentence[i]!='\0'){ //convert to upper for each character sentence[i] = toUpper(sentence[i]); i++; } } //converting all sentences into uppercase void convertAll(char **sentenceList, int numOfSentences){ int i=0; while(i<numOfSentences){ //calling convertsentence function to conver uppercase convertSentence(sentenceList[i]); i++; } } sentences.c #include<stdio.h> #include<stdlib.h> #include "convert.c" int main(){ //declaring character array char **mySentences; int noOfSentences;...
Given a database with the following tables: Students FirstName CHAR(20) | LastName CHAR(20) | StudentID INT | Major CHAR(20) | Degree CHAR(5) | Scholarship BOOLEAN | GPA FLOAT(3,2) | CreditsEarned INT | CreditsAttempted INT Classes ClassID INT | Title VARCHAR(50) | Description VARCHAR(255) | Credits SMALLINT Enrollments ClassID INT | StudentID INT C) Retrieve the First Name, Last Name, Major and StudentID of all students with a Scholarship:
using c++ Write a C++ program which reads three values of types char, int, double and string from the keyboard and primis, appropriately formatted, assigned values and variable types. For example, if letter, number, and real are variables of type char, int and double respectively, and if the values assigned to them using cin function are: a, 1, and 3.1415, then the output should be: a is a character 1 is an integen 3.1415 is a real number
Which of the following types can be safely compared using the == operator? A- string b- float c- double d- Char 2- What will be stored in variable i after the following statement is executed? int i = (int) Math.sqrt(5);
Which of the following reactions would constitute a reasonable synthesis of propyl acetate?
Consider the following methods’ headers: public static int one(int a, char b, double c, String d) public static double two(double x, double y) public static char three(int r, int s, char t, double u) Answer the following questions: Q1) What is the signature of method one? Answer: Q2) What is the return type of method two? Answer: Q3) What the formal parameters of method three? Answer: Q4) How many actual parameters are needed to call the method three? Answer: Q5)...